package com.hos.hospital.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hos.hospital.dao.DoctorRepository;
import com.hos.hospital.entity.Admin;
import com.hos.hospital.entity.Doctor;
import com.hos.hospital.entity.Messages;
import com.hos.hospital.entity.Section;
import com.hos.hospital.service.AdminService;
import com.hos.hospital.service.DoctorService;
import com.hos.hospital.service.SectionService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class  DoctorServiceImp implements  DoctorService  {

	@Autowired
	private  DoctorRepository  de;
	


	@Override
	public List<Doctor> findAll(Doctor doctor) {
		// Probe: 含有对应字段的实例对象。
		// ExampleMatcher：ExampleMatcher携带有关如何匹配特定字段的详细信息，相当于匹配条件。
		// Example：由Probe和ExampleMatcher组成，用于查询。
		Example<Doctor> example = Example.of(doctor);
		return de.findAll(example);
	}

	
	
	@Override
	public List<Doctor> findAllById(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void flush() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void deleteInBatch(Integer id) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void deleteAllInBatch() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Admin getOne(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public List<Doctor> findAll() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public Page<Doctor> findAll(Doctor doctor, int page, Integer size) {
	    ExampleMatcher matcher = ExampleMatcher.matching()
	            .withMatcher("name",ExampleMatcher.GenericPropertyMatchers.contains());//全部模糊查询，即%{address}%
	    Example<Doctor> example = Example.of(doctor ,matcher);
	   //设置分页
		Sort sort = Sort.by(Sort.Direction.DESC, "id");
		Pageable pageable = PageRequest.of(page, size,sort);
	
		return de.findAll(example,pageable);
	}

	

 
	
	
}
